Skip to main content

Globals

In this section we will review the Global functions available in the Mixcraft controller scripting API.

Log(args)

  • The Log() function prints strings to the in-application log window. This is useful for debugging and confirming values.

Parameters

  • args (variable or string) - The Log() function can print the stored value of an existing variable as well as strings, which can be concatenated to create helpful log entries.

Example

Globals.Log("MIDI channel" + midiChannel + " and MIDI CC number is " + value1);

SetDebug(bool)

  • The SetDebug() function enables the in-application script editor, MIDI monitor and console, which are launched after the script is selected in the Mixcraft Preferences menu. Generally, it's best to always have this set to true and comment out the line when you are done using debug mode.

Parameters

  • True (bool) - The debug enable state

Example

Globals.SetDebug(true); 

StartTimer(timerID, time)

The StartTimer() function starts the defined timerID, which will run for the supplied argument of time in milliseconds.

Paramteters

  • timerID (int) - The timer to start
  • time (int) - The duration of time to run the timer in milliseconds

Example

Globals.StartTimer(FLASH_TIMER, 250);

StopTimer(timerID)

  • The StopTimer() function stops the defined timerID.

Parameters

  • timerID (int) - The timer to stop

Example

Globals.StopTimer(ANIMATION_TIMER);

IsTimerRunning(timerID)

The IsTimerRunning() function returns a bool based on wether the timer ID supplied as an argument is running or not.

Paramteters

  • timerID (int) - The timer to start

Example

ANIM_TIMER = 0x01;
Globals.IsTimerRunning(ANIM_TIMER);

ToHexString(number, padding)

  • The ToHexString() function was added as there isn’t a function for this in javascript. The padding argument is the minimum number of digits. As the name implies, it will accept an integer and convert it to a hexadecimal string.

Parameters

  • number (int) - The integer value to convert ot a hexadecimal string
  • padding (int) - The minimum number of digits

Example

// This will convert the decimal value of 100 to a string of the 
// hex value, 64
Globals.ToHexString(100, 2)